package com.xin.di.uav.applet.controller;

import com.xin.di.uav.applet.service.IOrderInfoService;
import com.xin.di.uav.common.request.order.FlightRequest;
import com.xin.di.uav.common.request.order.LandingRequest;
import com.xin.di.uav.common.request.order.PickUpCodeRequest;
import com.xin.di.uav.common.request.order.TakOffRequest;
import com.xin.di.uav.common.utils.Rs;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @author LTQ
 */
@RestController
@RequestMapping("/home/external/order/")
@Slf4j
public class OutOrderPublicController {



    @Autowired
    private IOrderInfoService iOrderInfoService;

    @PostMapping("update-status-by-sn")
    @CrossOrigin
    @Operation(tags = "更新订单进度", description = "更新订单进度")
    public Rs<Void> updateStatusBySn(@Valid @RequestBody FlightRequest flightRequest) {
        log.warn(flightRequest.toString());
        iOrderInfoService.updateStatusBySn(flightRequest);
        return Rs.fYSuccess();
    }

    @PostMapping("take-off-notify")
    @CrossOrigin
    @Operation(tags = "起飞响应", description = "起飞响应")
    public Rs<Void> takeOffNotify(@Valid @RequestBody TakOffRequest takOffRequest) {
        log.warn(takOffRequest.toString());
        iOrderInfoService.takeOffNotify(takOffRequest);
        return Rs.fYSuccess();
    }


    @PostMapping("landing-notify")
    @CrossOrigin
    @Operation(tags = "降落响应", description = "降落响应")
    public Rs<Void> landingNotify(@Valid @RequestBody LandingRequest landingRequest) {
        log.warn(landingRequest.toString());
        iOrderInfoService.landingNotify(landingRequest);
        return Rs.fYSuccess();
    }


    @PostMapping("connection-cabinet-notify")
    @CrossOrigin
    @Operation(tags = "接驳柜响应", description = "接驳柜响应")
    public Rs<Void> pickUpCodeNotify(@Valid @RequestBody PickUpCodeRequest pickUpCodeRequest) {
        log.warn(pickUpCodeRequest.toString());
        iOrderInfoService.pickUpCodeNotify(pickUpCodeRequest);
        return Rs.fYSuccess();
    }


}
